package com.wise.service.portal.content.resourcegroups;

import com.wise.entities.content.ResourceGroup;
import com.wise.entities.content.ResourceStatus;
import com.wise.framework.dao.SqlSelect;
import com.wise.framework.daomodel.DaoList;
import com.wise.model.content.resourcegroup.ResourceGroupType;
import com.wise.summer.v1.portal.content.resourcegroups.ListResourceGroups;
import org.springframework.stereotype.Service;
import org.summerframework.model.SummerService;
import org.summerframework.model.SummerServiceBean;

import java.util.List;

@Service
@SummerService
public class ListResourceGroupsService implements SummerServiceBean<ListResourceGroups> {

	@Override
	public void sum(ListResourceGroups summer) {
		SqlSelect sql = SqlSelect.selec("*")
				.fromClassName(ResourceGroup.class)
				.eqLang(ResourceGroup._lang)
				.eq(ResourceGroup._groupType, ResourceGroupType.FILE.value())
				.eq(ResourceGroup._status, ResourceStatus.Normal.value());
		List<ListResourceGroups.Result> resourceGroupResultList = DaoList.s(ListResourceGroups.Result.class, sql);
		summer.setSummerResult(resourceGroupResultList);
	}

}
